
package com.engine4cloud.tdf.supervision.controller.inner;

import com.engine4cloud.tdf.common.core.util.R;
import com.engine4cloud.tdf.common.data.web.response.PageInfo;
import com.engine4cloud.tdf.common.log.annotation.SysLog;
import com.engine4cloud.tdf.common.security.annotation.Inner;
import com.engine4cloud.tdf.supervision.dto.create.TerminalBiologyCreateDTO;
import com.engine4cloud.tdf.supervision.dto.query.TerminalBiologyQueryDTO;
import com.engine4cloud.tdf.supervision.dto.result.JzdxTerminalBiologyResultDTO;
import com.engine4cloud.tdf.supervision.dto.result.TerminalBiologyResultDTO;
import com.engine4cloud.tdf.supervision.dto.update.TerminalBiologyUpdateDTO;
import com.engine4cloud.tdf.supervision.service.JzdxBiologyFeatureService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.*;

/**
 * 生物特征
 *
 * @author inner
 * @date 2024-04-26 14:44:20
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("/inner/biology")
@Tag(description = "biology", name = "矫正对象-生物特征-inner")
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
public class JzdxBiologyFeatureInnerController {

    private final JzdxBiologyFeatureService biologyFeatureService;

    /**
     * 分页查询
     *
     * @return R<PageInfo < RcglHelpResultDTO>>
     */
    @Inner
    @Operation(summary = "分页查询", description = "分页查询")
    @PostMapping("/page")
    public R<PageInfo<JzdxTerminalBiologyResultDTO>> pageList(@Valid @RequestBody TerminalBiologyQueryDTO dto) {
        return R.ok(biologyFeatureService.pageList(dto));
    }

    /**
     * 通过身份证号查询
     *
     * @param identity 身份证号
     * @return R
     */
    @Inner
    @Operation(summary = "通过身份证号查询", description = "通过身份证号查询")
    @GetMapping("/{identity}")
    public R<TerminalBiologyResultDTO> getByIdentity(@Schema(description = "身份证号") @PathVariable("identity") String identity) {
        return R.ok(biologyFeatureService.findOne(identity));
    }

    /**
     * 新增生物特征
     *
     * @param dto 新增生物特征
     * @return R
     */
    @Inner
    @Operation(summary = "新增生物特征", description = "新增生物特征")
    @SysLog("新增生物特征")
    @PostMapping
    public R<Boolean> create(@Valid @RequestBody TerminalBiologyCreateDTO dto) {
        return R.ok(biologyFeatureService.create(dto));
    }

    /**
     * 修改生物特征
     *
     * @param dto 生物特征
     * @return R
     */
    @Inner
    @Operation(summary = "修改生物特征", description = "修改生物特征")
    @SysLog("修改生物特征")
    @PutMapping
    public R<Boolean> update(@Valid @RequestBody TerminalBiologyUpdateDTO dto) {
        return R.ok(biologyFeatureService.update(dto));
    }
}